﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace AFanDa.DAL
{
    public interface IRepository<T> where T : class, new()
    {
        /// <summary>
        /// 添加单个
        /// </summary>
        /// <param name="t"></param>
        void Add(T t);
        /// <summary>
        /// 修改单个
        /// </summary>
        /// <param name="t"></param>
        void Update(T t);
        /// <summary>
        /// 删除单个
        /// </summary>
        /// <param name="t"></param>
        void Delete(T t);
        /// <summary>
        /// 添加多个
        /// </summary>
        /// <param name="Ie"></param>
        void AddRange(IEnumerable<T> Ie);
        /// <summary>
        /// 修改多个
        /// </summary>
        /// <param name="Ie"></param>
        void UpdateRange(IEnumerable<T> Ie);
        /// <summary>
        /// 删除多个
        /// </summary>
        /// <param name="Ie"></param>
        void DeleteRange(IEnumerable<T> Ie);

        int SaveChange();
        /// <summary>
        /// 查询所有
        /// </summary>
        /// <param name="where">条件</param>
        /// <returns></returns>
        IQueryable<T> QueryAll(Expression<Func<T, bool>> where = null);
        /// <summary>
        /// 查询所有 在排序
        /// </summary>
        /// <typeparam name="type"></typeparam>
        /// <param name="order">排序条件</param>
        /// <param name="isAsc">升序或者降序</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        IQueryable<T> QueryAll<type>(Expression<Func<T, type>> order, bool isAsc = true, Expression<Func<T, bool>> where = null);
        /// <summary>
        /// 查询所有 排序后分页
        /// </summary>
        /// <typeparam name="type"></typeparam>
        /// <param name="total">总数据数量</param>
        /// <param name="skip">第几页</param>
        /// <param name="take">跳过多少条</param>
        /// <param name="order">排序条件</param>
        /// <param name="isAsc">升序或者降序</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        IQueryable<T> QueryAll<type>(out int total, int? skip, int? take, Expression<Func<T, type>> order, bool isAsc, Expression<Func<T, bool>> where = null);




    }
}
